package second50;

import org.junit.jupiter.api.Test;

import java.util.Deque;
import java.util.LinkedList;


public class T0088 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int mi = m - 1;
        int ni = n - 1;
        int index = m + n - 1;
        while (ni >= 0) {
            if (mi >= 0 && nums1[mi] > nums2[ni]) {
                nums1[index] = nums1[mi];
                mi--;
                index--;
            } else {
                nums1[index] = nums2[ni];
                ni--;
                index--;
            }
        }
        return;
    }

    @Test
    public void test() {
        int[] nums1 = {1, 2, 3, 0, 0};
        int[] nums2 = {1, 2};
        merge(nums1, 3, nums2, 2);
        for (int i = 0; i <nums1.length ; i++) {
            System.out.print(nums1[i]+" ");
        }
        System.out.println();
    }
}
